package com.lynbermt.lodge;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.TypedArray;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;

public class LodgeActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Gallery g = (Gallery) findViewById(R.id.gallery);
        g.setAdapter(new ImageAdapter(this));
        
        //Friend Finder Button Info
        TextView friendFinderBtn = (TextView)findViewById(R.id.friendFinderBtn);
        friendFinderBtn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent launchFriendFinder = new Intent(LodgeActivity.this,FriendFinderActivity.class);
				startActivity(launchFriendFinder);
			}
		});
        
        //Event List Button Info
        TextView eventListBtn = (TextView)findViewById(R.id.eventsBtn);
        eventListBtn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent launchEventList = new Intent(LodgeActivity.this,EventListActivity.class);
				startActivity(launchEventList);
			}
		});
        
        //Nav Button Info
        TextView navBtn = (TextView)findViewById(R.id.navBtn);
        navBtn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
			    Intent navActivity = new Intent(Intent.ACTION_VIEW, Uri.parse("google.navigation:///?q=2240%20van%20hill%20rd%20greeneville%2C%20tn"));
			    startActivity(navActivity);
			}
		});
    }
    
  
    public class ImageAdapter extends BaseAdapter {
        int mGalleryItemBackground;
        private Context mContext;

        private Integer[] mImageIds = {
                R.drawable.image1,
                R.drawable.image2,
                R.drawable.image3,
                R.drawable.image4                
        };

        public ImageAdapter(Context c) {
            mContext = c;
            TypedArray a = obtainStyledAttributes(R.styleable.LodgeGallery);
            mGalleryItemBackground = a.getResourceId(
                    R.styleable.LodgeGallery_android_galleryItemBackground, 0);
            a.recycle();
        }

        public int getCount() {
            return mImageIds.length;
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(mContext);

            i.setImageResource(mImageIds[position]);
            i.setLayoutParams(new Gallery.LayoutParams(366, 244));
            i.setScaleType(ImageView.ScaleType.FIT_XY);
            i.setBackgroundResource(mGalleryItemBackground);

            return i;
        }
    }//end ImageAdapter
}//end Activity
